import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { WordService } from './service/word.service';
import { RequirePermission } from '@/common/decorator/require-premission.decorator';
import { Word, WordDto } from './dto';
@Controller('system/word')
export class WordController {
    constructor(private wordService: WordService) {

    }

    @RequirePermission("system:word:list")
    @Get('/getWord')
    getWord(@Query('name') name: string) {
        return this.wordService.getWord(name)

    }

    @Get('/getOptions')
    getOptions() {
        return this.wordService.getTable()
    }

    @RequirePermission("system:word:list")
    @Post('/find')
    findWord(@Body('name') name: string, @Body('id') id: number) {
        // console.log(name,id);
        return this.wordService.findWord(name, id)
    }

    @RequirePermission("system:word:list")
    @Post('/updateWord')
    updateWord(@Body('name') name: string,  @Body('word') word: Word) {
        console.log(name,word);
        
        return this.wordService.updateWord(name,word)
    }

    @RequirePermission("system:word:list")
    @Post('/addWord')
    addWord(@Body('name') name: string, @Body('newone') word: WordDto) {
        

        return this.wordService.addWord(name, word)
    }

    @RequirePermission("system:word:list")
    @Post('/delWord')
    delWord(@Body('name') name: string, @Body('id') id: number) {
        console.log(name,id);
        
        return this.wordService.delWord(name, id)
    }
}
